﻿namespace NumericalData
open System
open NumericalData
open NumericalData.Exceptions    
    ///// {=========================Rates=========================}
    type Rates = 
        class
            ///-----------------------------Fields-----------------------------

            ///-----------------------------Constructors-----------------------------

            ///-----------------------------Properties-----------------------------

            ///-----------------------------Operators-----------------------------

            ///-----------------------------Methods-----------------------------
            static member public MRate (matr:SquareMatrix) = 
                Rates.MRate matr.InnerArray

            static member public MRate (matr:Matrix) = 
                Rates.MRate matr.InnerArray

            static member public MRate (vec:Vector) = 
                Rates.MRate ([|vec.InnerArray|])

            static member public FrobeniusRate (matr:SquareMatrix) = 
                Rates.FrobeniusRate matr.InnerArray

            static member public FrobeniusRate (matr:Matrix) = 
                Rates.FrobeniusRate matr.InnerArray

            static member public FrobeniusRate (vec:Vector) = 
                Rates.FrobeniusRate ([|vec.InnerArray|])

            static member internal FrobeniusRate (mass:double[][]) = 
                mass|>
                Array.Parallel.map (
                        Array.fold (fun acc el ->
                            acc + Math.Pow(el,2.)) 0.)|>
                Array.sum |>
                (fun sumres -> Math.Sqrt(sumres))

            static member internal MRate (mass:double[][]) = 
                mass |>
                Array.Parallel.map (
                    Array.fold (fun acc el ->
                        acc + Math.Abs(el)) 0. 
                    )|>
                Array.max

        end
